$(function(argument) {
	var uid = window.localStorage.getItem("user_id");
	var val = window.sessionStorage.getItem("val");
	var type = window.sessionStorage.getItem("type");
	
	// 点击商品
	$(document).on("click", ".goods", function() {
		var gid = $(this).eq(0).attr('data-goods_id');
		window.sessionStorage.setItem("gid", gid);
		window.location.href = "tea_detail.html";
	})
	// 点击商户
	$(document).on("click", ".shops", function() {
		var sid = $(this).eq(0).attr('data-seller_id');
		window.sessionStorage.setItem("sid", sid);
		window.location.href = "waterBusinessperson.html";
	})

	$.ajax({
		url: 'http://www.teaweilai.com/app/Admin/AppSearch/search',
		type: 'POST',
		dataType: 'json',
		data: {
			val: val,
			type: type
		},
		success: function(data) {
			console.log(data);
			console.log(val);console.log(type);
				var data1=trans(data.sing)
			if (type == 1) {
				$('.titleTea h3').html('搜索商品')
				var str = template("seaGoods", {
					conGoods: data1
				});
				$(".container").html(str);
			}else{
				$('.titleTea h3').html('搜索店铺')
				var strShop = template("cityShop", {
					conGoods: data1
				});
				$(".container").html(strShop);
			}
		}
	})
	function trans(a){
		if(Object.prototype.toString.call(a)=='[object Array]') return a;
		return Object.keys(a).map(function(k){return a[k]});
	}
})